/*
SerialHex - A tool for reading and writing serial port data
Copyright (C) 2007  Patrick J. McCarty

This file is part of SerialHex. SerialHex is free software;
you can redistribute it and/or modify it under the terms of the 
GNU General Public License as published by the Free Software Foundation;
either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Text;
using System.IO.Ports;

namespace TEAM.SerialTXRX
{
	public partial class SerialPortSettings
	{
		private SerialDevice serialDevice;

        private string _DeviceName = String.Empty;
        private string _PortName = String.Empty;
        private int _BoundRate = 0;

		public SerialPortSettings()
		{
			
		}
        public SerialPortSettings(string PortName, int BoundRate)
            : base()
        {
            _PortName = PortName;
            _BoundRate = BoundRate;
        }

        public string DeviceName
        {
            get
            {
                return _DeviceName;
            }
            set
            {
                _DeviceName = value;
            }
        }

        public string PortName
        {
            get
            {
                return _PortName;
            }
            set
            {
                _PortName = value;
            }
        }

        public int BaudRate
        {
            get
            {
                return _BoundRate;
            }
            set
            {
                _BoundRate = value;
            }
        }

        //public string DeviceName
        //{
        //    get
        //    {
        //        return lblDeviceName.Text;
        //    }
        //    set
        //    {
        //        lblDeviceName.Text = value;
        //    }
        //}

        //public string PortName
        //{
        //    get
        //    {
        //        return cbbPortName.Text;
        //    }
        //    set
        //    {
        //        cbbPortName.Text = value;
        //    }
        //}

        //public string BaudRate
        //{
        //    get
        //    {
        //        return cbbBaudRate.Text;
        //    }
        //    set
        //    {
        //        cbbBaudRate.Text = value;
        //    }
        //}

		public void Initialize(SerialDevice serialDeviceP)
		{
            serialDevice = serialDeviceP;
            ConnectPort(this.PortName);
		}

        public void ConnectPort(string PortName)
        {
            if (serialDevice.Connect(PortName))
            {
                                
            }
        }
        public void DisconnectPort()
        {
            if (serialDevice.Disconnect())
            { 
            }
        }
	}
}
